<%@ page import="pojo.Point" %>
<%@ page import="java.util.List" %>
<%--
  Created by IntelliJ IDEA.
  User: 21131
  Date: 2023/11/25
  Time: 14:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>批改过的考试界面</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        /*试卷名*/
        h2 {
            text-align: center;
        }

        /*整张试卷*/
        .shijuan {
            text-align: center;
            display: inline-block;
            width: 70%;
            background-color: whitesmoke;
            margin-left: 8%;
            margin-right: 15%;
            display: inline-block;
        }

        /*一道考题*/
        .kaoti {
            padding-left: 0;
            text-align: left;
            margin-top: 5px;
        }

        /*分值和题型*/
        span {
            color: #8c8c8c;
        }

        /*系统自动批卷显示的错误答案*/
        .wrong_answer {
            background-color: #ce8483;
            /*width: 80%;*/
            height: 40px;
            color: white;
            line-height: 40px;
        }

        /*系统自动批卷显示的正确答案*/
        .right_answer {
            background-color: #3c763d;
            /*width: 80%;*/
            height: 40px;
            color: white;
            line-height: 40px;
        }

        /*试卷的选项*/
        .xuanxiang {
            padding-left: 15px;
            margin-top: 5px;
        }

        ul, li {
            list-style: none;
        }

        /*答题框的内容，每个选项*/
        ul li a {
            width: 40px;
            height: 33px;
            line-height: 33px;
            text-decoration: none;
            color: black;
            border: 1px solid black;
            margin-left: 4%;
            margin-top: 2%;
            margin-bottom: 2%;
            text-align: center;
            display: inline-block;
        }

        .timu {
            margin-top: 3px;
        }

    </style>
</head>
<body>

<%
    int number;
    String full_marks1 = session.getAttribute("corrected_full_marks").toString();//获取试卷的满分
    float full_marks = Float.parseFloat(full_marks1);
    String studentName=session.getAttribute("student_name").toString();

%>
<a href="${pageContext.request.contextPath }/goBack"
   style="display: inline-block;height: 30px;text-decoration: none;line-height: 30px; background-color: #66afe9; font-size: 15px; float: left;color: black"><strong><</strong>返回上一级</a>

<div class="shijuan">
    <div style="border-bottom: 1px solid;margin-top: 1%;padding-bottom: 1%">
        <% String name = session.getAttribute("corrected_exam_name").toString();%>
        <h1>
            <%=name%>
        </h1>
        <div style="color: rgba(15,0,12,0.94);">满分：<%=full_marks%>  &nbsp &nbsp &nbsp &nbsp &nbsp
            答卷人：<%=studentName%></div>
    </div>

    <div class="kaoti">
        <ul>
            <%--  学生参加考试的试卷的内容--%>
            <%
                List<Point> sc = (List<Point>) session.getAttribute("corrected_exam_contents");
                int flag = 1;
                number = 1;
                for (Point c : sc) {
            %>
            <li id="ti<%=number%>">
                <div class="timu">
                    <i><%=number%>.
                    </i><%=c.getQuestion().getQ_content()%><span>(<%=c.getQuestion().getQ_type()%>，分值为:<%=c.getMark()%>)</span><br>
                    <%--                    //传递题号--%>
                    <input name="tihao<%=number%>" style="display: none" value="<%=c.getQ_id()%>">
                </div>
                <%
                    //                    题型为单选题
                    if (c.getQuestion().getQ_type().trim().equals("单选题")) {
                %>
                <div class="xuanxiang">
                    <ul>
                        <%--选项A--%>
                        <li class="option">
                            <input type="radio" name="answer<%=number%>" value="A"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                A.
                                <p style="display: inline;"><%=c.getQuestion().getOp_A()%>
                                </p>
                            </label>

                        </li>
                        <%--选项B--%>
                        <li class="option">
                            <input type="radio" name="answer<%=number%>" value="B"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                B.
                                <p style="display: inline;"><%=c.getQuestion().getOp_B()%>
                                </p>
                            </label>
                        </li>
                        <%--选项C--%>
                        <li class="option">
                            <input type="radio" name="answer<%=number%>" value="C"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                C.
                                <p style="display: inline;"><%=c.getQuestion().getOp_C()%>
                                </p>
                            </label>
                        </li>
                        <%--选项D--%>
                        <li class="option">
                            <input type="radio" name="answer<%=number%>" value="D"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                D.
                                <p style="display: inline;"><%=c.getQuestion().getOp_D()%>
                                </p>
                            </label>
                        </li>
                    </ul>
                </div>
                <%
                } else if (c.getQuestion().getQ_type().trim().equals("多选题")) {//题型为多选题
                %>
                <div class="xuanxiang">
                    <ul>
                        <%--选项A--%>
                        <li class="option">
                            <input type="checkbox" name="answer<%=number%>" value="A"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                A.
                                <p style="display: inline;"><%=c.getQuestion().getOp_A()%>
                                </p>
                            </label>
                        </li>
                        <%--选项B--%>
                        <li class="option">
                            <input type="checkbox" name="answer<%=number%>" value="B"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                B.
                                <p style="display: inline;"><%=c.getQuestion().getOp_B()%>
                                </p>
                            </label>
                        </li>
                        <%--选项C--%>
                        <li class="option">
                            <input type="checkbox" name="answer<%=number%>" value="C"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                C.
                                <p style="display: inline;"><%=c.getQuestion().getOp_C()%>
                                </p>
                            </label>
                        </li>
                        <%--选项D--%>
                        <li class="option">
                            <input type="checkbox" name="answer<%=number%>" value="D"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                D.
                                <p style="display: inline;"><%=c.getQuestion().getOp_D()%>
                                </p>
                            </label>
                        </li>
                    </ul>
                </div>
                <%
                } else if (c.getQuestion().getQ_type().trim().equals("判断题")) {//判断题
                %>
                <div class="xuanxiang">
                    <ul>
                        <%--选项A--%>
                        <li class="option">
                            <input type="radio" name="answer<%=number%>" value="A"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                A.
                                <p style="display: inline;"><%=c.getQuestion().getOp_A()%>
                                </p>

                            </label>
                        </li>
                        <%--选项B--%>
                        <li class="option">
                            <input type="radio" name="answer<%=number%>" value="B"
                                   id="option<%=flag%>"/>
                            <label for="option<%=flag++%>">
                                B.
                                <p style="display: inline;"><%=c.getQuestion().getOp_B()%>
                                </p>
                            </label>
                        </li>
                    </ul>
                </div>
                <%
                    }
                    number++;
                    String myanswer = session.getAttribute("myAnswer" + c.getQ_id()).toString();
                    if (session.getAttribute("flag" + c.getQ_id()).toString().trim().equals("right")) {
                %>
                <div class="right_answer">答对了，您的选项为：<%=myanswer%>，正确选项为<%=c.getQuestion().getQ_standard()%>
                </div>
                <%
                } else {
                %>
                <div class="wrong_answer">答错了，您的选项为：<%=myanswer%>，正确选项为<%=c.getQuestion().getQ_standard()%>
                </div>
                <% }
                }
                %>
            </li>
        </ul>
    </div>
</div>
</body>
</html>
